package com.team7.controller;

import com.alibaba.fastjson.JSON;
import com.team7.common.vo.CommonResult;
import com.team7.common.vo.TeacherCheckVo;
import com.team7.service.CheckTeacherService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * @program: team7-Object02
 * @description: 讲师审核调用层
 * @author: 王子鑫
 * @create: 2021-10-20 15:58
 **/

@RestController
@RequestMapping("service/checkTeacher")
public class CheckTeacherController {
    @Resource
    private CheckTeacherService checkTeacherService;

    @PostMapping("/findCheckTeacher/{page}/{limit}")
    public CommonResult findCheckTeacher(
            @PathVariable("page") Integer page,@PathVariable("limit") Integer limit,
            @RequestBody TeacherCheckVo teacherCheckVo){
        CommonResult checkTeacher = checkTeacherService.findCheckTeacher(page, limit, teacherCheckVo);
        return checkTeacher;
    }

    @PostMapping("/changeCheckTeacher")
    public CommonResult changeCheckTeacher(@RequestBody TeacherCheckVo teacherCheckVo){
        LocalDateTime now = LocalDateTime.now();
        String nowTime = JSON.toJSONString(now);
        teacherCheckVo.setCheckTime(nowTime);
        CommonResult commonResult = checkTeacherService.changeCheckTeacher(teacherCheckVo);
        return commonResult;
    }

    @PostMapping("/changeTeacherInfo")
    public CommonResult changeTeacherInfo(@RequestBody TeacherCheckVo teacherCheckVo){
        CommonResult commonResult = checkTeacherService.changeTeacherInfo(teacherCheckVo);
        return commonResult;
    }
}
